<?php
/**
 * XmuSlh, web platform of Student Association Federation of Xiamen University
 * 
 * Rewritting one or some pages of StatusNet. 
 * To get the original version, please visit <http://status.net/>.
 * 
 * StatusNet, the distributed open-source microblogging tool
 * 
 * LICENCE: This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * Base class for search box and its result item.
 * With autocomplete features.
 * 
 * Widgets for displaying a search box and result sytle or same.
 * Includes a input and a button widget and its specific item widget.
 * 
 * 用来显示一个搜索框的控件.
 * MUST include the 'autocomplete' js libaray.
 * 
 * @author		ytukie <ytukie@gmail.com>
 * @version		0.2
 * 
 * 0.2)  Css modified.
 */

// XmuSlh only.
if ( !defined('XMUSLH')) { exit(1); }

// Requirements.
require_once INSTALLDIR . '/lib/slh_widget.php';
require_once INSTALLDIR . '/lib/slh_util.php';

// Definitions.


/**
 * Widget for displaying Seach box.
 */
class SearchBox extends Widget
{
	/**
	 * Several actions relative url.
	 */
	var $searchjsonaction = null;
	var $resultaction = null;
	var $goaction = null;
	
	/**
	 * Constructor.
	 */
	function __construct($actions, $out = null)
	{
		parent::__construct($out);
		$this->searchjsonaction = $actions['s'];
		$this->resultaction = $actions['r']; 
		$this->goaction = $actions['g'];
	}
	
	/**
	 * Show the search box.
	 */
	function show()
	{
		$this->out->elementStart('div', array('id' => 'searchbox'));
		
		// The js variables.
		$this->out->hidden('id_searchjsonaction', slh_full_path('index.php/'.$this->searchjsonaction.'/'));
		$this->out->hidden('id_resultaction', slh_full_path('index.php/'.$this->resultaction.'/'));
		$this->out->hidden('id_goaction', slh_full_path('index.php/'.$this->goaction.'/'));
		
		$this->out->elementStart('fieldset');
		
		$this->out->elementStart('p', array('id' =>'id_div_typein'));
		$this->out->input('id_input_search', '');
		/*
		$this->out->element('input', array('id' => 'id_btn_go',
										   'type' => 'button',
										   'onClick' => 'go();'));
		*/
		$this->out->elementEnd('p');
		
		$this->out->element('div', array('id' => 'id_div_searchresult'));
		
		$this->out->elementEnd('fieldset');
		$this->out->elementEnd('div');
	}
	
}

?>